from odoo import fields, models, api
from odoo.exceptions import UserError


class RPPostalCodeInheritForAPI(models.Model):
    _inherit = 'rp.postal.code'

    def printf_for_api(self):
        return {'id': self.id,
                'name': self.name,
                'display': '{} - {}'.format(self.name, self.city_id.name),
                'country': {'id': self.country_id.id,
                            'name': self.country_id.name},
                'state': {'id': self.state_id.id,
                          'name': self.state_id.name},
                'city': {'id': self.city_id.id,
                         'name': self.city_id.name},
                'county': {'id': self.county_id.id,
                           'name': self.county_id.name},
                }
